<?php
require("conexao.php");
session_start();
 $_SESSION["autenticado"]= "SI"; 
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$txt_login = $_POST["txt_login"];
$txt_senha = md5($_POST["txt_senha"]);

$sql = "select * from usuario where login = '$txt_login' and senha = '$txt_senha'";
$resultado = mysql_query($sql);
$linha = mysql_fetch_array($resultado);

if (mysql_num_rows($resultado)>0)
{

$user["ID"]= $linha["idusuario"];
$user["NOME"]= $linha["nome"];
$user["EMAIL"]= $linha["email"];
$user["LOGIN"]=$linha["login"];
$user["SENHA"]=$linha["senha"];
$user["DATA_CAD"]=$linha["data_cad"];


$_SESSION["user"] = $user;


print "<script type = 'text/javascript'> location.href = 'index2.php?link=4'</script>";
}
else
{
unset($_SESSION["txt_login"]);
unset($_SESSION["txt_senha"]);
?>
<script>
history.back();
</script>
<?php
}
?>
</body>
</html>
